// 公共方法封装

/**
 * 清除上下文
 */
export const destroy = (scene, renderer, animationID) => {
  try {
    scene.traverse(child => {
      if (child.material) {
        child.material.dispose();
      }
      if (child.geometry) {
        child.geometry.dispose();
      }
      child = null;
    });
    scene.clear();
    renderer.dispose();
    renderer.forceContextLoss();
    renderer = null;
    // 去除animationFrame
    cancelAnimationFrame(animationID);
    // let gl = renderer.domElement.getContext("webgl");
    // gl && gl.getExtension("WEBGL_lose_context").loseContext();
  } catch (e) {
    console.log(e)
  }
}
